home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 107_01.zip / CLOGS.DOC < prev    next >
Text File  |  1993-06-06  |  7KB  |  249 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                       NOTES ON "LOG" FUNCTIONS FOR BDS - C
  8.  
  9.  
  10.                                   Introduction
  11.  
  12.  
  13.       These "log" functions were developed so that I could do some auxiliary
  14.  
  15. work on scaling and curve generation for a graphics package I'm now doing in
  16.  
  17. BDS-C.  They seem to work OK in my setup which is now:  
  18.  
  19.        o  Altair 8800b, 64K CPM 2.2 BDS-C vers 1.44 
  20.  
  21.        o  Tarbell SSSD 4 8 inch disk 
  22.  
  23.        o  Scion Microangelo 
  24.  
  25.        o  LSI ADM3A 
  26.  
  27. This package was developed by:  
  28.  
  29. L. C. Calhoun PE 
  30.  
  31. 257 South Broadway 
  32.  
  33. Lebanon, Ohio 45036 
  34.  
  35. <513> 932-4541/433-7510 
  36.  
  37.                        SPECIAL NOTE ON VERSION OF BDS - C
  38.  
  39.  
  40.       The CLOGS programs have been written to take advantage of the ability to
  41.  
  42. insert '\0' into string constants which make it possible to use string constant
  43.  
  44. as pseudo-static floating point constants.  
  45.  
  46.  
  47.  
  48.       These programs are written in BDS-C using the floating point package
  49.  
  50. modified to add truncation and magnitude functions.  This package is called
  51.  
  52. "FLOAT+44".  The following functions are mechanized:  
  53.  
  54.      char *expe(result,x) 
  55.  
  56.      char *result, *x;   /* usual [5] char arrays for fp */ 
  57.  
  58.           The program returns the base of natural logs "e" raised to the power
  59.  
  60.           given in x.  The program is limited to work within the bounds of the
  61.  
  62.  
  63.  
  64.  
  65.  
  66.                                         1
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.           floating point variable.  The function returns the pointer to the
  77.  
  78.           result.  Values outside floating point bounds for the result are set
  79.  
  80.           to either zero or a very large number on the order of 2e38.  No error
  81.  
  82.           flags exist or are set.  
  83.  
  84.      char *exp10(result,x) 
  85.  
  86.      char *result, *x;   /* as with expe */ 
  87.  
  88.           Identical to expe, except the base of briggs logs "10" is raised to
  89.  
  90.           the power indicated by x.  
  91.  
  92.      char *log10(result,sign,x) 
  93.  
  94.      char *result, *x;    /*as with expe */ 
  95.  
  96.      int *sign; 
  97.  
  98.      char *angle, *datum;    
  99.  
  100.           This returns the logarithm to the base 10 in result of the value in x.
  101.  
  102.           x is unchanged.  Logarithms are computed of the magnitude of x, and
  103.  
  104.           negative x values return a -1 in sign.  Positive x values produce a 1
  105.  
  106.           in sign.  Very large or small values are returned for out   of range
  107.  
  108.           data.  There is no over/underflow indication.  Also returns pointer to
  109.  
  110.           result.  
  111.  
  112.                                      Method
  113.  
  114.  
  115.       The methods used are outlined in "Functional Approximations" by Fred
  116.  
  117. Ruckdeschel; page 34 ff in BYTE for November 1978.  Note the corrections in the
  118.  
  119. January 1979 issue.  A number of references are given in that article, and are
  120.  
  121. recommended reading.  There is an error in Ruckdeschel' article, in Table 3b.
  122.  
  123. The term to the right of the equals should all be enclosed in brackets and
  124.  
  125. squared.  Refer to equation 4.2.47 in Ruckdeshel' reference 6.  The following
  126.  
  127. service function is used:  
  128.  
  129.      int exprange(x) 
  130.  
  131.  
  132.  
  133.  
  134.  
  135.                                         2
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.      char *x; 
  146.  
  147.           This is used in the series evaluations.  Input is a pointer to the
  148.  
  149.           BDS-C type floating point variable.  It returns a 1 (true) if -47 <=
  150.  
  151.           exponent <= 47.  Outside of the range of exponent a 0 (false) is
  152.  
  153.           returned.  The exponent is a power of 2, so the effective range is
  154.  
  155.           about 1.4e14 to 7.e-15 for exponent in decimals.  The function is used
  156.  
  157.           to avoid a series computation overflowing the exponent which wraps a
  158.  
  159.           small exponent into a large one and vice-versa.  
  160.  
  161.  
  162.  
  163.       A number of checks are made for very large and very small data, to protect
  164.  
  165. the evaluation from the underflow and overflow failures of the floating point
  166.  
  167. package.  I have used TESTCLOG to evaluate over a wide range of variables, and I
  168.  
  169. think! I got all the gotchas.  It looks as though the package has (except at
  170.  
  171. infinity) about an absolute accuracy of .00001.  You will note that I use the
  172.  
  173. properties of the floating point numbers to do magnitude and sign checks.  Lots
  174.  
  175. faster than using fpcomp().  There is another program included, COEFSTAT, which
  176.  
  177. I used to derive the five octal equivalents for the pseudo-static terms in the
  178.  
  179. series evaluations, etc.  This will only work with BDS C V 1.44 (and later, I
  180.  
  181. hope) which allows insertion of nulls ('\0') in string constants.  The string
  182.  
  183. constants are used as pseudo-static floating point constants..and work very
  184.  
  185. well.  
  186.  
  187.  
  188.  
  189.                         Components of the CLOGS Package
  190.        1. CLOGS.DOC             This documentation file 
  191.  
  192.        2. CLOGS.C               Source for trig package 
  193.  
  194.        3. COEFSTAT.C            Source for coeficient determing program 
  195.  
  196.        4. TESTCLOG.C            Source for trig function testing program 
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.                                         3
  205.  
  206.  
  207.  
  208. power);
  209.     fpsub(x,x,tenfac);
  210.     fpasg(tenfac,one);
  211.     while (tenpower)
  212.         Software contributions are received for inclusion into the
  213.   library with the understanding that the contributor is
  214.   authorized to make the material available to others for their
  215.   individual, non-commercial use.  The Users Group makes no
  216.   representations as to the utility of the material in the
  217.   library for any purpose.  Contributions should be submitted
  218.   on 8" single density diskettes in CP/M file form.  Please
  219.   cross reference any rewrites or bug-fixes to prior
  220.   distributions
  221.  
  222. National CP/M Users Group - Program Submission Form
  223.  
  224. Submission Date: 27 July 1981 
  225.  
  226. Files names:    FLOAT+44.*  Files pertaining to a modified
  227.                 floating point package for
  228.                 BDS-C.  These files upgrade
  229.                 my previous FLOATXT.*
  230.                 submission.  Files are
  231.         FLOAT+44.C  Source, includes fixed "z" in _spr
  232.         FLOAT+44.CRL compiled version with V 1.44
  233.         FLOAT+44.DOC Documentation from FLOAT.DOC, updated
  234.         NEWFLVAL.C   Source of test program for float pkg
  235.         NEWFLVAL.CRL compiled version with V 1.44 & FLOAT+44
  236.         NEWFLVAL.COM linked version with FLOAT+44 for test
  237.  
  238.         COEFSTAT.C   Source of program to derive octal string
  239.                 equivalent of fp constants
  240.         COEFSTAT.CRL compiled version with V 1.44
  241.  
  242.         CTRIG.C      Source of updated trignometric functions
  243.                 working with BDS-C V 1.44 and FLOAT+44
  244.                 Update of CTRIG previously submitted
  245.                 to BDS-C UG.
  246.         CTRIG.CRL    compiled version with V 1.44
  247.         CTRIG.DOC    Documentation of above.
  248.         TESTTRIG.C   Source of program to exercise CTRIG
  249.         TESTTRIG.CRL comp